<template>
	<view class="index">
		<view class="tags">
			<view @click="changeAvatar">
				<view v-for="(item,index) in imgList" :key="index" class="tag">
					<image class="tag-img" :src="imgList[index]"></image>
					<text class="tag-text">以图识图</text>
				</view>
			</view>
			<block v-for="(value, index) in data" :key="index">
				<view class="tag" @tap="goList(value)" style="width: 25%;">
					<image class="tag-img" :src="value.icon"></image>
					<text class="tag-text" style="overflow:hidden;
text-overflow:ellipsis;
white-space:nowrap;
width: 100%;">{{value.name}}</text>
				</view>
			</block>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data: [],
				imgList: [
					"../../static/upload.png"
				],
				//文件实体地址，搜索完后根据该地址进行删除
				filePath: '',
				//搜索的图片指纹
				fingerprint: ''
			}
		},
		onShow: function(options) {
			var that = this
			uni.showLoading({
				title: "页面刷新中"
			});
			setTimeout(function() {
				//执行请求获取分类信息
				uni.request({
					url: that.$serverUrl + 'tagList',
					method: 'GET',
					header: {
						//token
						'token': uni.getStorageSync('token')
					},
					success: (ret) => {
						console.log('ret.data.data', ret.data.data)
						that.data = ret.data.data
					}
				});
				uni.hideLoading();
			}, 500);
		},
		methods: {
			goList(value) {
				uni.navigateTo({
					url: '../list/list?title=' + value.name + '&id=' + value.id
				})
			},
			//以图识图
			changeAvatar(e) {
				uni.navigateTo({
					url: '/pages/upload/upload?type=0',
					
				})
			},
		}
	}
</script>

<style>

</style>
